<?php
	include_once('classes/view.php');
	
	if($_POST){
		try{
			$MyPath 	= ".\\Scripts\\";
			$MyResult 	= array();
			$MyBack 	= "";
			
			if(isset($_POST['submit_gpu'])){
				$MyPath 	.= "ComputeGraphics.exe " . $_POST['szerokosc_szyny'] . " " . $_POST['czestotliwosc_pracy'] . " " . $_POST['tryb_pracy'];
				$MyBack  	= "&nbsp;&nbsp;<a href=\"compute_graphic.php\" >Powrót</a>";
			}else if(isset($_POST['submit_data'])){
				$MyPath		.= "ConsoleParameters.exe " . $_POST['kind_usb'] . " " . $_POST['spec_usb'] . " " . $_POST['data_to_transfer'];
				$MyBack  	= "&nbsp;&nbsp;<a href=\"compute_data_transfer.php\" >Powrót</a>";
			}
			
			//print_r($MyPath); die();
			$MyTmp = exec($MyPath, $MyResult);
			
			
			View::displayHeader();
			
			echo '<br /><br /><br /><p align="center">';
			
			for($i = 0; $i < count($MyResult); $i++){
				echo '&nbsp;' . $MyResult[$i];
			}
			
			echo '<br /><br />' . $MyBack . '</p><br /><br />';
			View::displayFooter();
		} catch (Exception $ex){
			View::displayHeader();
			View::displayMiddle("Błąd podczas wykonywania skryptu: " . $ex->getMessage());
			View::displayFooter();
		}
	}
	die();
?>